﻿
-----------------------------------------------------------------------
-- MatrixTimer.lua
--
-- A Framework for World Of Warcraft addons
-- Copyright (C) 2007  wwkkii
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- any later version.
-- 
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
-- 
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
-- 
-- Home Page: http://code.google.com/p/wowmatrix
-----------------------------------------------------------------------

local __version__ = { "MatrixTimer", 0, 1, 1 };
if (MatrixUpdateVersion(__version__)) then return; end

-------------------------------------------------------------------------------
-- local variables
-------------------------------------------------------------------------------

local function Matrix_SetTimer(nm,tmout,proc,arg)
	local node = { };

	if ((nm == nil) or (nm == "")) then
		return nil;
	end
	if ((tmout <= 0) or (proc == nil)) then
		matrix.timers[nm] = nil;
		return nil;
	end
	node = matrix.timers[nm];
	if (node == nil) then
		node = { };
		node.name = nm; 
		matrix.timers[nm] = node;
	end 
	node.tmout = tmout + tmout;
	node.next = matrix.tickCount + node.tmout;
	node.proc = proc;
	node.arg = arg;
	return 1;
end

local function Matrix_KillTimer(nm)
	matrix.timers[nm] = nil;
end
